<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改大区会长预订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-agentorder-edit" th:object="${zsyhAgentOrder}">
            <h4 class="form-header h4">大区会长预订单信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">大区会长id：</label>
                <div class="col-sm-8">
                    <input name="agentId" th:field="*{agentId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <select name="orderState" class="form-control m-b" th:with="type=${@dict.getType('agent_order_state')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{orderState}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收货人：</label>
                <div class="col-sm-8">
                    <input name="orderName" th:field="*{orderName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">收货电话：</label>
                <div class="col-sm-8">
                    <input name="orderPhone" th:field="*{orderPhone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">详细地址：</label>
                <div class="col-sm-8">
                    <input name="orderAddress" th:field="*{orderAddress}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">预订合计金额：</label>
                <div class="col-sm-8">
                    <input name="orderBeginMoney" th:field="*{orderBeginMoney}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">发货合计金额：</label>
                <div class="col-sm-8">
                    <input name="orderEndMoney" th:field="*{orderEndMoney}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">大区会长地址id：</label>
                <div class="col-sm-8">
                    <input name="agentAddressId" th:field="*{agentAddressId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">厂家id：</label>
                <div class="col-sm-8">
                    <input name="factoryId" th:field="*{factoryId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">平台是否已确认 1是 0否：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('zsyh_yesno')}">
                        <input type="radio" th:id="${'isEnsurePlatform_' + dict.dictCode}" name="isEnsurePlatform" th:value="${dict.dictValue}" th:field="*{isEnsurePlatform}">
                        <label th:for="${'isEnsurePlatform_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">大区会长预订单详细信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addColumn()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delColumn()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "zsyh/agentorder";
        $("#form-agentorder-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-agentorder-edit').serialize());
            }
        }

        $(function() {
            var options = {
                data: [[${zsyhAgentOrder.zsyhAgentOrderRelList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'partsId',
                    align: 'center',
                    title: '配件id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].partsId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'attributeId',
                    align: 'center',
                    title: '型号id',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].attributeId' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'orderCount',
                    align: 'center',
                    title: '预订数量',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].orderCount' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'orderPrice',
                    align: 'center',
                    title: '单价',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].orderPrice' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].createTime' value='%s'>", index, value);
                        return html;
                    }
				},
                {
                    field: 'updateTime',
                    align: 'center',
                    title: '更新时间',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='zsyhAgentOrderRelList[%s].updateTime' value='%s'>", index, value);
                        return html;
                    }
				
                }]
            };
            $.table.init(options);
        });

        function addColumn() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            sub.editColumn();
        	
            $("#" + table.options.id).bootstrapTable('insertRow', {
                index: count,
                row: {
                    index: $.table.serialNumber(count),
                    partsId: "",
                    attributeId: "",
                    orderCount: "",
                    orderPrice: "",
                    createTime: "",
                    updateTime: ""
        	    }
            });
        }
    </script>
</body>
</html>